package com.my.juc.test;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/5/6 20:45
 */
public class Demo {

    public static void main(String[] args) {
        
        FutureTask<Object> task = new FutureTask<>(new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                System.out.println("哈哈哈");
                return new String("OK");
            }
        });
        Thread thread = new Thread(task);
        
        thread.start();
        
        System.out.println("t1哈哈哈");
        try {
            System.out.println("task.get() = " + task.get());
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }
    }
    
}
